package com.loveprogrammer.eternity.skill.support.skills;

import com.loveprogrammer.eternity.model.Character;
import com.loveprogrammer.eternity.common.Tuple;
import com.loveprogrammer.eternity.skill.support.states.PoisoningState;
import com.loveprogrammer.eternity.skill.support.states.TreatmentState;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @version 1.0.0
 * @description: 鼓舞
 * @author: eric
 * @date: 2022-08-30 18:01
 **/
public class InspireSkill extends AbstractSkill {

    public InspireSkill(int id, int baseInterval, int level, int order, int maxLevel, String name, String desc) {
        super(id, baseInterval, level, order, maxLevel, name, desc);
    }

    @Override
    protected Tuple<String, List<Character>> skillLaunch(Character character,
                                                         List<? extends Character> attack,
                                                         List<? extends Character> defences) {
        Tuple<String, List<Character>> result = new Tuple<>();
        // 友方提升 恢复力  护甲 和 技巧
        int increment = getHarm(character);
        for (Character member : attack) {
            member.setArmature(member.getArmature() + (increment/3+10));
            member.setTechnique(member.getTechnique() + increment);
            TreatmentState treatmentState = new TreatmentState(member, defences, (increment/2+10));
            setTimeTask(treatmentState, 10);
        }
        timer.newTimeout(timeout -> {
            for (Character member : attack) {
                member.setArmature(member.getArmature() - (increment/3+10));
                member.setTechnique(member.getTechnique() - increment);
            }
        }, 10, TimeUnit.SECONDS);

        result.setKey(character.getName() + "释放了技能【" + getName() + " (" + getLevel() + "级)】，所有友方角色护甲提升"
                + (increment/3+10) + "点，每秒恢复生命值" + (increment/2+10) + "点，技巧提升" + increment + "点" );
        result.setValue(new ArrayList<>());

        return result;
    }

    @Override
    protected int computeHarm(Character character) {
        return (int) (character.getTechnique() * 0.2 + getLevel() * 30);
    }

    @Override
    protected int computeSecondHarm(Character character) {
        return 0;
    }

    @Override
    public boolean check(Character character) {
        if(restInterval() <= 0) {
            return true;
        }
        return false;
    }

    @Override
    public int opportunityPassive() {
        return 0;
    }

    @Override
    public boolean checkLevelUp(int characterLevel) {
        // 每3级升一级
        if(characterLevel % 3 == 0){
            return true;
        }
        return false;
    }

    @Override
    public int defaultHarm() {
        return 0;
    }
}
